home *** CD-ROM | disk | FTP | other *** search
- /* fclose.c - close a stream.
- (C) Copyright 1984 Gregory R. Mansfield - All Rights Reserved.
- G. R. Mansfield. 84/06/09.
- Ver 1.3-5108.
- */
-
- #include <stdio.h>
-
- int fclose(fp) /* close a stream */
- FILE *fp;
- {
- int q, r;
-
- if (fp->_flag & _WRITE == 0)
- r = EOF;
- else {
- if (((fp->_flag & _UNBUF) == 0) && (fp->_ptr != 0))
- fflush(fp);
- r = 0;
- }
- q = close(fp->_fd);
- fp->_flag = 0;
- fp->_cnt = 0;
- return(r ? r : q);
- }
-